//! 集成测试
//! 
//! 测试整个汇编流程

use chinese_assembler::*;

#[test]
fn test_basic_instruction() {
    let source = "移动 累加器，10";
    let lexer = Lexer::new(source);
    let mut parser = Parser::new(lexer).unwrap();
    let program = parser.parse_program().unwrap();
    
    assert_eq!(program.statements.len(), 1);
    if let Statement::Instruction(inst) = &program.statements[0] {
        assert_eq!(inst.name, "移动");
        assert_eq!(inst.operands.len(), 2);
    } else {
        panic!("期望是指令语句");
    }
}

#[test]
fn test_arithmetic_instructions() {
    let source = "加 累加器，基址\n减 累加器，10";
    let lexer = Lexer::new(source);
    let mut parser = Parser::new(lexer).unwrap();
    let program = parser.parse_program().unwrap();
    
    assert_eq!(program.statements.len(), 2);
}

#[test]
fn test_label() {
    let source = "开始：\n移动 累加器，10";
    let lexer = Lexer::new(source);
    let mut parser = Parser::new(lexer).unwrap();
    let program = parser.parse_program().unwrap();
    
    assert_eq!(program.statements.len(), 2);
    if let Statement::Label(name, _line) = &program.statements[0] {
        assert_eq!(name, "开始");
    } else {
        panic!("期望是标签");
    }
}

